package com.oasistudio.ads.expert.banner;

import android.app.Activity;
import android.widget.LinearLayout;

import com.oasistudio.ads.expert.R;
import com.wiyun.ad.AdView;

public class AdViewWiyun extends AdView{
	WiyunAdRequestListener adRequestListener;
	Activity activity;
	LinearLayout wiyunContainer;
	public static final String UNION = "wiyun.com";
	public AdViewWiyun(Activity activity){
		super(activity);
		this.activity = activity;
		this.adRequestListener = new WiyunAdRequestListener(activity, UNION);
		super.setListener(this.adRequestListener);
		addWiyunAd();
	}
	
	@Override
	public void requestAd(){
		this.adRequestListener.beforeAdRequest();
		super.requestAd();
	}
	
	/************************ www.wiyun.com start ***********************/
	private void addWiyunAd() {
		LinearLayout adContainer = (LinearLayout) activity.findViewById(R.id.ads_container);
		adContainer.addView(new TitleBuilder().createTitle(activity, UNION));

		wiyunContainer = new LinearLayout(activity);
		adContainer.addView(wiyunContainer);
		//com.wiyun.ad.AdView ad = new com.wiyun.ad.AdView(activity);
		this.setResId("21f6f98cc305da1f");//0ed22e25c334c703
		wiyunContainer.addView(this, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
		this.requestAd();
	}
	/************************ www.wiyun.com end ***********************/
	
	class WiyunAdRequestListener extends AbstractAdsExpertAdListener implements AdListener{
		public WiyunAdRequestListener(Activity activity, String union){
			super(activity, union);
		}
		@Override
		public void onAdClicked() {
			// TODO Auto-generated method stub
			this.adClicked();
		}

		@Override
		public void onAdLoadFailed() {
			// TODO Auto-generated method stub
			this.fail();
		}

		@Override
		public void onAdLoaded() {
			// TODO Auto-generated method stub
			this.succeed();
			AdHistory.saveAd(UNION, wiyunContainer);
		}

		@Override
		public void onAppDownloadFailed() {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void onAppDownloaded() {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void onExitButtonClicked() {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void onMiniSiteClosed() {
			// TODO Auto-generated method stub
			
		}
	}
}
